import javax.swing.plaf.SliderUI;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-02-04
 * Time: 12:32
 */
class Solution5 {
    public boolean validPalindrome(String s) {
        int n = s.length();
        int left = 0, right = n - 1;
        int count = 0;
        while (left < right) {
            char ch1 = s.charAt(left);
            char ch2 = s.charAt(right);
            if (ch1 == ch2) {
                left++;
                right--;
            } else {
                if (left <= n - 2 && right >= 1) {
                    char ch3 = s.charAt(left + 1);
                    char ch4 = s.charAt(right - 1);
                    if (ch3 == ch2) {
                        count++;
                        left++;
                    } else if (ch4 == ch1) {
                        count++;
                        right--;
                    } else {
                        return false;
                    }
                }
            }
        }
        if(count > 1) {
            return false;
        }
        return true;
    }
}
public class Test5 {
    public static void main(String[] args) {
        String s = "aguokepatgbnvfqmgmlcupuufxoohdfpgjdmysgvhmvffcnqxjjxqncffvmhvgsymdjgpfdhooxfuupuculmgmqfvnbgtapekouga";
        Solution6 solution6 = new Solution6();
        solution6.validPalindrome(s);
    }
}
